package com.zhongkun.datahome.service.repository;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhongkun.datahome.service.constant.MaterialTypeEnum;
import com.zhongkun.datahome.service.domain.DecorationStandardItem;
import com.zhongkun.datahome.service.mapper.DecorationStandardItemMapper;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Author: lifengsheng
 * @Date: 2025/4/17 13:36
 * @Desc
 */
@Repository
public class DecorationStandardItemRepository extends ServiceImpl<DecorationStandardItemMapper, DecorationStandardItem> {

    public List<DecorationStandardItem> listByStandardId(Long standardId) {
        return this.list(new LambdaQueryWrapper<DecorationStandardItem>()
                .eq(DecorationStandardItem::getStandardId, standardId)
                .orderByDesc(DecorationStandardItem::getId));
    }

    public List<DecorationStandardItem> listBySkuId(Long skuId) {
        return this.list(new LambdaQueryWrapper<DecorationStandardItem>()
                .eq(DecorationStandardItem::getMaterialType, MaterialTypeEnum.COMMON_SKU.getType())
                .eq(DecorationStandardItem::getMaterialId, skuId));
    }

    public void removeBatchByStandardIds(List<Long> standardIds) {
        this.remove(new LambdaQueryWrapper<DecorationStandardItem>()
                .in(DecorationStandardItem::getStandardId, standardIds));
    }
}
